/*
 * @Author: chaoxiaoshu-mx leukotrichia@163.com
 * @Date: 2023-02-09 16:23:08
 * @LastEditors: chaoxiaoshu-mx leukotrichia@163.com
 * @LastEditTime: 2023-02-10 17:46:29
 * @FilePath: \node-server\routes\index.js
 * @Description: 路由
 */
var express = require('express');
let fs = require('fs')
var path = require("path");

var router = express.Router();

// 跨域
router.all('*', function (req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS');
  res.header("Access-Control-Allow-Headers", "X-Requested-With");
  res.header('Access-Control-Allow-Headers', 'Content-Type');
  next();
});

router.get('/', function(req, res) {
  res.send("Node Server");
});

router.get('/test', function(req, res) {
  let data = fs.readFileSync(path.join(__dirname, 'test.vue'));
  res.send(data);
});

module.exports = router;